package cn.shentianlan.controller;

import cn.shentianlan.criteria.CourseCriteria;
import cn.shentianlan.domain.dto.CourseDTO;
import cn.shentianlan.service.CourseService;
import cn.shentianlan.utils.Result;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 陈俊源
 * @Description TODO
 * @Date 2021/4/20
 * @Version 1.0
 */
@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdateCourse(CourseDTO courseDTO){
        Result result = courseService.saveOrUpdateCourse(courseDTO);
        return result;
    }

    @PostMapping("/list")
    public Result findCourseByCourseCriteria(CourseCriteria criteria){
        Result result = courseService.findCourseByCourseCriteria(criteria);
        return result;
    }

    @RequestMapping("/getCourseById")
    public Result getCourseById(Long id){
        Result result = courseService.getCourseById(id);
        return result;
    }

    @RequestMapping("/deleteCourseById")
    public Result deleteCourseById(Long id){
        Result result = courseService.deleteCourseById(id);
        return result;
    }
}
